Skip to main content

Defined in: src/constructs/cloudwatch-dashboard/cloudwatch-dashboard.ts:100

A CloudWatch dashboard construct with sensible defaults and built-in description widget.

This construct extends the CloudWatch Dashboard directly and provides:

  • A prominent text widget displaying the dashboard description at the top
  • Optional initial widgets that can be specified during construction
  • Direct access to all CloudWatch Dashboard methods and properties
  • Automatic removal policy application for easy teardown in ephemeral environments

The construct follows AWS best practices for dashboard design by including descriptive documentation directly in the dashboard interface.

Example

// Basic usage with description only
const dashboard = new CloudWatchDashboard(this, 'AppDashboard', {
dashboardName: 'application-monitoring',
dashboardDescription: 'Monitors API performance and error rates'
});

// Add widgets after creation - direct dashboard access
dashboard.addWidgets(
new cloudwatch.GraphWidget({
title: 'API Requests',
left: [apiRequestMetric],
})
);

// Advanced usage with initial widgets and custom removal policy
const advancedDashboard = new CloudWatchDashboard(this, 'DetailedDashboard', {
dashboardName: 'detailed-monitoring',
dashboardDescription: 'Comprehensive monitoring for production workloads',
periodOverride: cloudwatch.PeriodOverride.AUTO,
removalPolicy: RemovalPolicy.RETAIN, // Keep dashboard when stack is deleted
initialWidgets: [
new cloudwatch.GraphWidget({
title: 'Error Rate',
left: [errorRateMetric],
width: 12,
height: 6,
}),
new cloudwatch.SingleValueWidget({
title: 'Total Requests',
metrics: [totalRequestsMetric],
width: 12,
height: 6,
}),
],
});

Extends

  • Dashboard

Constructors

Constructor

new CloudWatchDashboard(scope, id, props): CloudWatchDashboard

Defined in: src/constructs/cloudwatch-dashboard/cloudwatch-dashboard.ts:108

Create a new CloudWatch dashboard with description widget and optional initial widgets.

Parameters

scope

Construct

The construct scope.

id

string

Logical ID for this construct.

props

CloudWatchDashboardProps

CloudWatchDashboardProps controlling dashboard name, description, and optional initial widgets.

Returns

CloudWatchDashboard

Overrides

cloudwatch.Dashboard.constructor

Properties

dashboardArn

readonly dashboardArn: string

Defined in: node_modules/.pnpm/aws-cdk-lib@2.232.1_constructs@10.0.5/node_modules/aws-cdk-lib/aws-cloudwatch/lib/dashboard.d.ts:102

ARN of this dashboard

Attribute

Inherited from

cloudwatch.Dashboard.dashboardArn


dashboardName

readonly dashboardName: string

Defined in: node_modules/.pnpm/aws-cdk-lib@2.232.1_constructs@10.0.5/node_modules/aws-cdk-lib/aws-cloudwatch/lib/dashboard.d.ts:96

The name of this dashboard

Attribute

Inherited from

cloudwatch.Dashboard.dashboardName


env

readonly env: ResourceEnvironment

Defined in: node_modules/.pnpm/aws-cdk-lib@2.232.1_constructs@10.0.5/node_modules/aws-cdk-lib/core/lib/resource.d.ts:80

The environment this resource belongs to.

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

Inherited from

cloudwatch.Dashboard.env


node

readonly node: Node

Defined in: node_modules/.pnpm/constructs@10.0.5/node_modules/constructs/lib/construct.d.ts:305

The tree node.

Stability

stable

Inherited from

cloudwatch.Dashboard.node


stack

readonly stack: Stack

Defined in: node_modules/.pnpm/aws-cdk-lib@2.232.1_constructs@10.0.5/node_modules/aws-cdk-lib/core/lib/resource.d.ts:79

The stack in which this resource is defined.

Inherited from

cloudwatch.Dashboard.stack


PROPERTY_INJECTION_ID

readonly static PROPERTY_INJECTION_ID: string

Defined in: node_modules/.pnpm/aws-cdk-lib@2.232.1_constructs@10.0.5/node_modules/aws-cdk-lib/aws-cloudwatch/lib/dashboard.d.ts:90

Uniquely identifies this class.

Inherited from

cloudwatch.Dashboard.PROPERTY_INJECTION_ID

Methods

addVariable()

addVariable(variable): void

Defined in: node_modules/.pnpm/aws-cdk-lib@2.232.1_constructs@10.0.5/node_modules/aws-cdk-lib/aws-cloudwatch/lib/dashboard.d.ts:121

Add a variable to the dashboard.

Parameters

variable

IVariable

Returns

void

See

https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_dashboard_variables.html

Inherited from

cloudwatch.Dashboard.addVariable


addWidgets()

addWidgets(...widgets): void

Defined in: node_modules/.pnpm/aws-cdk-lib@2.232.1_constructs@10.0.5/node_modules/aws-cdk-lib/aws-cloudwatch/lib/dashboard.d.ts:115

Add a widget to the dashboard.

Widgets given in multiple calls to add() will be laid out stacked on top of each other.

Multiple widgets added in the same call to add() will be laid out next to each other.

Parameters

widgets

...IWidget[]

Returns

void

Inherited from

cloudwatch.Dashboard.addWidgets


applyRemovalPolicy()

applyRemovalPolicy(policy): void

Defined in: node_modules/.pnpm/aws-cdk-lib@2.232.1_constructs@10.0.5/node_modules/aws-cdk-lib/core/lib/resource.d.ts:116

Apply the given removal policy to this resource

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters

policy

RemovalPolicy

Returns

void

Inherited from

cloudwatch.Dashboard.applyRemovalPolicy


toString()

toString(): string

Defined in: node_modules/.pnpm/constructs@10.0.5/node_modules/constructs/lib/construct.d.ts:319

Returns a string representation of this construct.

Returns

string

Stability

stable

Inherited from

cloudwatch.Dashboard.toString


isConstruct()

static isConstruct(x): x is Construct

Defined in: node_modules/.pnpm/constructs@10.0.5/node_modules/constructs/lib/construct.d.ts:299

(deprecated) Checks if x is a construct.

Parameters

x

any

Any object.

Returns

x is Construct

true if x is an object created from a class which extends Construct.

Deprecated

use x instanceof Construct instead

Inherited from

cloudwatch.Dashboard.isConstruct


isOwnedResource()

static isOwnedResource(construct): boolean

Defined in: node_modules/.pnpm/aws-cdk-lib@2.232.1_constructs@10.0.5/node_modules/aws-cdk-lib/core/lib/resource.d.ts:78

Returns true if the construct was created by CDK, and false otherwise

Parameters

construct

IConstruct

Returns

boolean

Inherited from

cloudwatch.Dashboard.isOwnedResource


isResource()

static isResource(construct): construct is Resource

Defined in: node_modules/.pnpm/aws-cdk-lib@2.232.1_constructs@10.0.5/node_modules/aws-cdk-lib/core/lib/resource.d.ts:74

Check whether the given construct is a Resource

Parameters

construct

IConstruct

Returns

construct is Resource

Inherited from

cloudwatch.Dashboard.isResource